<div class="content-wrapper">
	<section class="content-header">
		<h1>岗位列表</h1>
		<ol class="breadcrumb">
			<li><a href="/admin"><i class="fa fa-dashboard"></i> 首页</a></li>
			<li class="active">账号管理</li>
			<li class="active">岗位列表</li>
		</ol>
	</section>
	<section class="content">
		<div class="box">
			<div class="box-header with-border">
				<form class="form-inline">
					<input type="hidden" name="id" id="id" value="{$positionInfo.id}" />
					<div class="form-group">
						<label for="name">岗位名 </label> 
						<input type="text" class="form-control" id="name" name="name" placeholder="岗位名" value="{$positionInfo.name}">
					</div>
					<div class="form-group">
						<label for="name">岗位编号 </label> 
						<input type="text" class="form-control" id="code" name="code" placeholder="岗位编号" value="{$positionInfo.code}">
					</div>					
					<button type="button" class="btn btn-info" id="save-btn">{$positionInfo?'修改':'添加'}</button>&nbsp;
					<button type="button" class="btn btn-danger" onclick="window.location.href='/admin/user/positionList'">取消</button>
				</form>
			</div>
			<div class="box-body">
				<table class="table table-bordered">
					<tbody>
						<tr>
							<th style="width: 40px">ID</th>
							<th>岗位名</th>
							<th>岗位编号</th>
							<th style="width: 215px">操作</th>
						</tr>
						<foreach name="positionList" item="position">
                        	<tr>
                        		<td>{$position.id}</td>
                        		<td>{$position.name}</td>
                        		<td>{$position.code}</td>
                        		<td>
                        			<button class="btn btn-info btn-xs" type="button" onclick="window.location.href='/admin/user/positionList?id={$position.id}'">修改</button>&nbsp;
                        		</td>
                        	</tr>
                        </foreach>
					</tbody>
				</table>
			</div>			
		</div>
	</section>
</div>

<script type="text/javascript">
$(function(){
	$("#save-btn").click(function(){
		var id = $("#id").val();
		var name = $.trim($("#name").val());
		var code = $.trim($("#code").val());
		
		if(name == '') {
			ArtDialogHlp.showInfo('提示', '请填写岗位名');
            return false;
        }
		
		if(code == '') {
			ArtDialogHlp.showInfo('提示', '请填写岗位编号');
            return false;
        }
		
		$.post('/admin/user/savePosition', {id:id, name:name, code:code}, function(data){
			if(data.Code == 999) {
				ArtDialogHlp.showInfo('提示', '操作成功', function(){
					window.location.href = '/admin/user/positionList';
				});
			} else {
				ArtDialogHlp.showInfo('提示', data.Msg);
			}
		}, 'json');
	});
});
</script>